package com.noahplat.person.controller;

import com.noahplat.common.utils.Result;
import com.noahplat.person.pojo.Physical;
import com.noahplat.person.service.PhysicalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

/**
 * @ClassName: PhysicalController
 * @Description: 体检记录controller
 * @Author 李景星
 * @Date 2021/3/8
 * @Version 1.0
 */
@RestController
@RequestMapping("/api/physical")
@Validated
public class PhysicalController {

    @Autowired
    private PhysicalService physicalService;


    /**
     * 获取体检记录
     * @param pid
     * @return
     */
    @PreAuthorize("hasAuthority('noahplat-service-person:PhysicalController:getPhysical')")
    @GetMapping("/getPhysical")
    public Result getPhysical(@NotNull(message = "人员ID不能为空 ") @Min(value = 1, message = "人员ID不合法") Long pid){
        return physicalService.getPhysical(pid);
    }

    /**
     * 更新体检记录
     * @param physical
     * @return
     */
    @PreAuthorize("hasAuthority('noahplat-service-person:PhysicalController:unpdatePhysical')")
    @PutMapping("/unpdatePhysical")
    public Result updatePhysical(@RequestBody Physical physical){
        return physicalService.updatePhysical(physical);
    }
}
